import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
import prettier from 'eslint-plugin-prettier'
export default defineConfig([
  globalIgnores(['dist', '**/auto-imports.d.ts', 'node_modules']),
  {
    files: ['**/*.{ts,tsx,js,jsx}'],
    extends: [
      js.configs.recommended,
      ...tseslint.configs.recommended,
      reactHooks.configs['recommended-latest'],
      reactRefresh.configs.vite,
      prettier.configs['recommended'],
    ],
    languageOptions: {
      ecmaVersion: 2022,
      sourceType: 'module',
      globals: globals.browser,
    },
    rules: {
      'no-unused-vars': 'off',
      '@typescript-eslint/no-unused-vars': [
        'error',
        {
          argsIgnorePattern: '^_',        // 允许函数参数以 _ 开头的不算未使用
          varsIgnorePattern: '^_',        // 允许变量以 _ 开头的不算未使用
          caughtErrorsIgnorePattern: '^_',// 允许 catch(e) 中 e 未使用
        }
      ],
      'react/prop-types': 'off', // TS 已有类型系统
    },
  },
])
